package middleware

import (
	"gitee.com/tiger000/taishan_web/taishan"
	"sync"
)

var middlewarePool sync.Map

func Register(middleware taishan.IMiddleware) {
	middlewarePool.Store(middleware.Name(), middleware)
}

func Load(name string) taishan.IMiddleware {
	value, ok := middlewarePool.Load(name)
	if ok {
		return value.(taishan.IMiddleware).New()
	}
	return nil
}
